<template>
  <div class="dialog-wrapper">
    <Modal v-model="show" v-bind:title="$t('m.repointOrder')" footer-hide :mask-closable="false">
      <Form ref="form" :model="form" :rules="rules" :label-width="60">
        <FormItem v-bind:label="$t('m.Account')" prop="managerId">
          <Select v-model="form.managerId" v-bind:placeholder="$t('m.selectZhipai')">
            <Option v-for="(item, index) in list" :key="index" :value="item.id">{{ item.account }}</Option>
          </Select>
        </FormItem>
        <FormItem style="margin-top: 36px;">
          <Button type="primary" @click="handleSubmit" :loading="btnLoading">{{ $t('m.submit')}}</Button>
        </FormItem>
      </Form>
    </Modal>
    <Modal v-model="reassignBox" :title="this.$t('m.repoint')+this.$t('m.dealResult')" @on-ok="reassignOk" @on-cancel="reassignOk">
      <table class="table table-hover table-condensed" border>
        <!-- <thead>
              </thead> -->
        <tbody>
          <!-- <tr v-show="orderGidReturnObj.editTotalNumbers">
            <td>{{ $t('m.zǒngshù') }}</td>
            <td>{{orderGidReturnObj.editTotalNumbers}}</td>
          </tr>
          <tr v-show="orderGidReturnObj.succTotalNumbers">
            <td>{{ $t('m.chénggōng') }}</td>
            <td>{{orderGidReturnObj.succTotalNumbers}}</td>
          </tr>
          <tr v-show="orderGidReturnObj.failTotalNumbers">
            <td>{{ $t('m.shībài') }}</td>
            <td>{{orderGidReturnObj.failTotalNumbers}}</td>
          </tr> -->
        </tbody>
      </table>
    </Modal>
  </div>
</template>

<script>
import { deepCopy } from '@/libs/util';
const COMPONENT_NAME = 'dialog-assign';
export default {
  name: COMPONENT_NAME,
  props: {
    value: Boolean,
    orderNums: Array,
    list: Array
  },
  data () {
    return {
      reassignBox: false,
      btnLoading: false,
      show: this.value,
      form: {
        managerId: ''
      },
      rules: {
        managerId: [
          { required: true, type: 'num', message: '请选择要指派的客服人员', trigger: 'change' }
        ]
      }
    }
  },
  mounted () {
  },
  watch: {
    value (val) {
      this.show = val;
    },
    show (val) {
      this.$refs.form.resetFields();
      this.$emit('input', val);
    }
  },
  methods: {
    // 表单提交
    handleSubmit () {
      const { form } = this.$refs;
      this.btnLoading = true;
      this.$http.post('/api/laocai/remind/reassign', {
        orderGids: this.orderNums,
        accountId: this.form.managerId
      }).then((res) => {
        if (res.body.code == 0) {
          this.btnLoading = false;
          this.reassignBox = true

        }
        this.$Message.success(this.$t('m.errorCode' + res.body.code));
        this.$emit('ok');
      });
    },
    reassignOk () {

      this.reassignBox = false
    }

  }
}
</script>

<style lang="scss">
.ivu-form .ivu-form-item-label {
  margin-bottom: 0;
}
</style>
